package main

import "fmt"

func twoSum(nums []int, target int) []int {
	mp := make(map[int]int)
	for idx, num := range nums {
		if pos, ok := mp[target-num]; ok {
			return []int{pos, idx}
		}
		mp[num] = idx
	}
	return nil
}

func main() {
	nums := []int{2, 7, 11, 15}
	target := 9
	res := twoSum(nums, target)
	for _, re := range res {
		fmt.Println(re)
	}
}
